package cn.shen.sheng.da.service.impl;


import cn.shen.sheng.da.model.bo.LoginStatusBO;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpSession;

@Component
public class LoginStatusManager  {
    private static final String SESSION_USER_STATUS = "user_status";

    public void setLoginStatus(HttpSession session, LoginStatusBO loginStatus) {
        session.setAttribute(SESSION_USER_STATUS, loginStatus);
        /*System.out.println("session = " + session);*/
    }

    public LoginStatusBO getLoginStatus(HttpSession session) {

        LoginStatusBO loginStatus = (LoginStatusBO) session.getAttribute(SESSION_USER_STATUS);
        System.out.println("loginStatus1111 = " + loginStatus);
        if (loginStatus == null) {
            loginStatus = new LoginStatusBO();
            setLoginStatus(session, loginStatus);
            System.out.println("loginStatus2 = " + loginStatus);
        }


        return loginStatus;
    }
}
